<template>
  <div>
    <!-- 搜索 -->
    <!-- 车型选择 -->
    <TopFilter :list="topFilterInit" :cols="3" :collapse="collapse" labelWidth="90" @filterChange="changeHandle"></TopFilter>
    <!-- table -->
    <FilterTable height="auto" selectionType="single" ref="table" :columns="columns" :params="fetchParams" :dataSource="dataList" :datakey="'records'" :fetchapi="fetchApi" :onColumnsChange="columns => (this.columns = columns)" :onRowSelectChange="selectChange"> </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button type="primary" :click="saveDialog.bind()" :disabled="disableds">添 加</multiuse-button>
      <multiuse-button @click="closeDialog" >关 闭</multiuse-button>
    </div>
  </div>
</template>
<script>
// import res from '@/mock/tableData';
import { getModelList } from '@/api/dictionary';
export default {
  // mixins: [dictionary],
  data() {
    return {
      disableds: true,
      dataList: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchApi: getModelList,
      fetchParams: {}, //ipa 接口
      selectedRows: [] //选中经销商
    };
  },
  created() {
  },
  methods: {
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      this.disableds = this.selectedRows.length <= 0;
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      this.$emit('save', this.selectedRows);
      console.log("选中车型",this.selectedRows)
    },
    //取消操作
    closeDialog() {
      this.$emit('close');
    },
    chooseOrderNo() {
      this.visible = true;
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = Object.assign({},val);
      console.log(val);
    },
    //搜索数据
    topFilterInitFun() {
      return [
        // { type: 'INPUT', label: '品牌代码', fieldName: 'brandCode', placeholder: '请输入', initialValue: '' },
        // { type: 'INPUT', label: '车系代码', fieldName: 'seriesCode', placeholder: '请输入', initialValue: '' },
        // { type: 'INPUT', label: '车型代码', fieldName: 'modelCode', placeholder: '请输入', initialValue: '' },
        { type: 'INPUT', label: '品牌', fieldName: 'brandName', placeholder: '请输入品牌...', initialValue: '' },
        { type: 'INPUT', label: '车系', fieldName: 'seriesName', placeholder: '请输入车系...', initialValue: '' },
        { type: 'INPUT', label: '车型', fieldName: 'modelName', placeholder: '请输入车型...', initialValue: '' }
      ];
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '品牌', dataIndex: 'brandName', sorter: true },
        { title: '车系', dataIndex: 'seriesName', sorter: true },
        { title: '车型', dataIndex: 'modelName', sorter: true }
      ];
    }
  }
  // mounted() {
  //   this.BaseTable = this.$refs.listModal.$refs.pageTable;
  // }
};
</script>

<style lang="less" scoped></style>
